package com.pengtu.gsj.dao.yh;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.pengtu.gsj.dao.hibernate.HibernateDao;
import com.pengtu.gsj.entity.yh.Reconstruction;

/**
 * 
 * 
 * ReconstructionDao
 * 
 * 2017年6月6日 下午1:40:23
 * @author lei
 * @version 1.0.0
 *
 */
@Repository
public class ReconstructionDao extends HibernateDao<Reconstruction, String> {

	public List<Reconstruction> getCountReconstructions(){
		String hql = "select new com.pengtu.gsj.entity.yh.Reconstruction(t.projectType,count(t.projectType)) from Reconstruction t where t.finished = '1' and t.delFlag='0' GROUP BY t.projectType ORDER BY t.projectType ";
		return find(hql);
	};
	
	public List<Reconstruction> getcountReconsGroupByType(String projectType){
		String hql = "select new com.pengtu.gsj.entity.yh.Reconstruction(t.projectType,t.projectYear,count(t.projectYear),sum(t.totalInvestment),sum(t.subsidyAmount),sum(t.selfRaised)) from Reconstruction t where t.projectType=? and t.delFlag='0' GROUP BY t.projectYear,t.projectType ORDER BY t.projectYear";
		return find(hql, projectType);
	}
	
	public List<Reconstruction> getCountReconstructions(String startTime, String endTime){
		String hql = "select new com.pengtu.gsj.entity.yh.Reconstruction(t.projectType,count(t.projectType)) from Reconstruction t where t.finished = '1' and t.delFlag='0' and t.projectYear >=? and t.projectYear <=? GROUP BY t.projectType ORDER BY t.projectType ";
		return find(hql, startTime, endTime);
	};
	
	public List<Reconstruction> getcountReconsGroupByType(String projectType, String startTime, String endTime){
		String hql = "select new com.pengtu.gsj.entity.yh.Reconstruction(t.projectType,t.projectYear,count(t.projectYear),sum(t.totalInvestment),sum(t.subsidyAmount),sum(t.selfRaised)) from Reconstruction t where t.projectType=? and t.delFlag='0' and t.projectYear >=? and t.projectYear <=? GROUP BY t.projectYear,t.projectType ORDER BY t.projectYear";
		return find(hql, projectType, startTime, endTime);
	}
	
	public List<Reconstruction> getcountReconsGroupByYear(String startTime, String endTime){
		String hql = "select new com.pengtu.gsj.entity.yh.Reconstruction(t.projectYear,count(t.projectYear),sum(t.totalInvestment),sum(t.subsidyAmount),sum(t.selfRaised)) from Reconstruction t where t.delFlag='0' and t.projectYear >=? and t.projectYear <=? GROUP BY t.projectYear ORDER BY t.projectYear";
		return find(hql, startTime, endTime);
	}
	
}
